<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
        
        <h1>首页</h1>
        <img src="./images/dy.jpg" alt="">
		<!--<form action="http://localhost:3000/upload" method="post" enctype="multipart/form-data">-->
			<input type="file" name="haha" class="files"  value="" />
			<input type="file" name="haha" class="files"  value="" />
			<input type="submit" class="btn" value="提交"/>
		<!--</form>-->
	</body>
	<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
	<script type="text/javascript">
		var fm = new FormData();
		$(".files").change(function(e){
			fm.append("file",e.target.files[0])
			
		})
//		$(".btn").click(function(){
//			var fl = document.querySelector(".files")
//			console.log(fl.files[0])
//		})

		$(".btn").click(function(){
				$.ajax({
					type:"post",
					url:"/upload",
					async:true,
					cache: false, //上传文件无需缓存
					processData: false, //用于对data参数进行序列化处理 这里必须false
					contentType: false, //必须
					data:fm,
					success:function(res){
						console.log(res)
					}
						
				});
		})
		

		
		
	</script>
</html>
